package cn.drh.charging.device.controller;


import cn.drh.charging.common.pojo.JsonResult;
import cn.drh.charging.common.pojo.vo.StationInfoVO;
import cn.drh.charging.common.pojo.param.GunStatusUpdateParam;
import cn.drh.charging.device.service.DeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName DeviceController
 * @Author renhong~Deng
 * @Date 2025/5/26 14:14
 * @Version 1.0
 */


@Slf4j
@RequestMapping("/device")
@RestController
@Api(tags = "设备服务")
public class DeviceController {

    @Autowired
    private DeviceService deviceService;

    /**
     * 获取场站信息
     * @param gunId 枪编号
     * @return 场站信息
     */
    @ApiOperation("获取场站信息")
    @GetMapping("/station/info/{gunId}")
    public JsonResult<StationInfoVO> getStationInfo(@PathVariable Integer gunId) {
        log.debug("获取场站信息的入参-{}", gunId);
        log.debug("获取场站信息调用service入参-{}", gunId);
        StationInfoVO stationInfoVO = deviceService.getStationInfo(gunId);
        log.debug("获取场站信息调用service入参-{},出参-{}", gunId, stationInfoVO);
        JsonResult jsonResult = JsonResult.ok(stationInfoVO, "获取场站信息成功");
        log.debug("获取场站信息的入参-{},出参-:{}", gunId, jsonResult);
        return jsonResult;
    }


    /**
     * 获取场站信息
     * @param gunStatusUpdateParam 枪编号
     * @return 场站信息
     */
    @ApiOperation("更新充电枪的状态")
    @PostMapping("/station/gun/status/update")
    public JsonResult<StationInfoVO> update(@RequestBody GunStatusUpdateParam gunStatusUpdateParam) {
        log.debug("更新枪的状态信息的入参-{}", gunStatusUpdateParam);
        log.debug("更新枪的状态信息调用service入参-{}", gunStatusUpdateParam);
        Boolean success = deviceService.updateGunStatus(gunStatusUpdateParam);
        log.debug("更新枪的状态信息调用service入参-{},出参-{}", gunStatusUpdateParam, success);
        JsonResult jsonResult = JsonResult.ok(success, "更新枪的状态成功");
        log.debug("更新枪的状态信息的入参-{},出参-:{}", gunStatusUpdateParam, jsonResult);
        return jsonResult;
    }

}
